GBML manual / Input

btn_dx

The d-pad’s horizontal axis: -1 (Left), 0, or 1 (Right). Both held at once cancels to 0. Add a player number from 1 to 4 to ask another controller: btn_dx(2).

Syntax

btn_dx(player = 1) -> int

Arguments

NameType
playerint (can be left out; then it is 1)

Returns

int

Description

The d-pad's horizontal axis, read as a single number: -1 while Left is held, 1 while Right is held, 0 otherwise. Holding both Left and Right at once cancels back to 0 rather than picking one arbitrarily.

Pairs with btn_dy for 8-way movement without four separate btn_held(BTN_LEFT)-style checks.

Another player

Write a player number from 1 to 4 in the brackets to read that player's d-pad: btn_dx(2). Leave it out and it is player 1, the same as writing 1. The number has to be written out in the call (not kept in a variable), and a console that has fewer controllers than that tells you so when you check the game: the Game Boy Advance has one, so only player 1 works there.

Example

hsp = btn_dx() * 1.5;

Drives horizontal movement straight off the d-pad's own axis reading.

On the GBA

The Game Boy Advance has one controller, so only player 1 can be asked here (written out or left out, it is the same call).

See also: btn_dyhsp